Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sbb-chip-group): initial implementation #3382

Open
wants to merge 28 commits into
base: main
Choose a base branch
from

Conversation

TomMenga
Copy link
Contributor

@TomMenga TomMenga commented Feb 3, 2025

Open topics

Preflight Checklist

Issue

This PR Closes #2761

Pull request checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

See Review Guidelines for more information what is checked during review process.

Changes

Changes in this pull request:

  • Created sbb-chip-group
  • Created sbb-chip

Browsers

I tested the build on the following browsers:

  • Firefox Desktop
  • Chrome Desktop
  • Edge Desktop
  • Safari Desktop
  • Chrome Mobile
  • Safari Mobile

Screen readers

I tested the build on the following browsers:

  • JAWS Firefox Desktop
  • JAWS Chrome Desktop
  • NVDA Firefox Desktop
  • NVDA Chrome Desktop
  • VoiceOver Safari Desktop
  • VoiceOver Chrome Desktop
  • VoiceOver Safari Mobile
  • Android Accessibility Suite Chrome Mobile

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

Does this introduce a breaking change?

  • Yes
  • No

Other information

@github-actions github-actions bot added target: 2.x pr: peer review required A peer review is required for this pull request labels Feb 3, 2025
@TomMenga TomMenga self-assigned this Feb 3, 2025
@TomMenga TomMenga added the pr: lead review required A lead review is required for this pull request label Feb 3, 2025
# Conflicts:
#	src/elements/autocomplete/autocomplete-base-element.ts
Copy link
Contributor

@DavideMininni-Fincons DavideMininni-Fincons left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good, some detail to fix

@@ -30,6 +30,11 @@ import style from './autocomplete-base-element.scss?lit&inline';
*/
const ariaRoleOnHost = isSafari;

/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have an events property?

let input: HTMLInputElement;
let focusStep: HTMLInputElement;

describe('basic interactions', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
describe('basic interactions', () => {
describe('sbb-chip-group', () => {

possibly adding a nested described with 'basic interaction'

});
});

describe.only('with autocomplete', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
describe.only('with autocomplete', () => {
describe('with autocomplete', () => {

};

// TODO
export const WithAutoComplete: StoryObj = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MEMO: remove todo

Suggested change
export const WithAutoComplete: StoryObj = {
export const WithAutocomplete: StoryObj = {

import style from './chip-group.scss?lit&inline';

/**
* Describe the purpose of the component with a single short sentence.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace this placeholder text

Comment on lines +51 to +71
const toRemove = [...oldValue];
for (const c of value) {
if (toRemove.includes(c)) {
toRemove.splice(toRemove.indexOf(c), 1);
}
}
toRemove.forEach((value) =>
this._chipElements()
.find((c) => c.value === value)
?.remove(),
);

// Subtract from the new 'value' what was already present
// The result are the new chips to add (handle duplicates)
const toAdd = [...value];
for (const c of oldValue) {
if (toAdd.includes(c)) {
toAdd.splice(toAdd.indexOf(c), 1);
}
}
toAdd.forEach((c) => this._createChipElement(c));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: could the usage of Set and Set's method (difference, insersection, etc) improve this code?

@@ -0,0 +1,52 @@
import { html } from 'lit';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove placeholder comments from this file


## Accessibility

The `sbb-chip-group` follows the `grid` pattern;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

infos are missing, or the ; must be replaced with .

Comment on lines +37 to +47
The `sbb-chip-group` has a `negative` variant. If within a `sbb-form-field`, the properties automatically sync.

```html
<sbb-form-field negative>
<sbb-chip-group name="field-name">
<sbb-chip value="Value 1"></sbb-chip>
...
<input />
</sbb-chip-group>
</sbb-form-field>
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can go in ## Style maybe?

import { i18nChipDelete } from '@sbb-esta/lyne-elements/core/i18n/i18n';

/**
* Describe the purpose of the component with a single short sentence.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this placeholder text

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: lead review required A lead review is required for this pull request pr: peer review required A peer review is required for this pull request target: 2.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sbb-chip-group: initial implementation
2 participants